<?php
namespace Site\Controller;
class PageController extends CommonController {
    public function index() {
        $data = $this->getPageList(M('Page'),array('sid'=>$this->sid));
        $this->display();
    }

    public function add() {
        if(IS_POST) {
            D('Page','Mysql')->addPage($_POST);
            $this->success('单页添加成功','/page');
        }else {
            $this->display();
        }
    }

    public function update() {
        if(IS_POST) {
            D('Page','Mysql')->updatePage($_POST);
            $this->success('单页修改成功','/page');
        }else {
            $id = I('get.id');
            verify($id,'isID','非法单页ID');

            $pageInfo = M('Page')->find($id);
            verify($pageInfo,'notEmpty','单页不存在');

            if($pageInfo['sid'] != $this->sid) {
                $this->error('请切换网站之后修改');
            }

            $this->assign('pageInfo',$pageInfo);
            $this->display();
        }

    }
}

?>
